﻿Imports System.Data
Imports System.IO

Namespace Arwani
    Partial Class Division
        Inherits System.Web.UI.MasterPage
        Protected SliderText As String = ""
        Protected Division_Title As String = ""
        Protected Division_Lower_Background As String = ""
        Protected Division_Header As String = ""
        Protected Division_Banner As String = ""
        Protected Slider_Script As String = ""
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            ' If Page.IsPostBack = True Then Exit Sub
            Call setPageSEOInformation()
            Call loadSliders()
            Call setDivisionSettings()



        End Sub

        Public Sub setPageSEOInformation()
            Dim thisURL As String = Request.Url.AbsoluteUri.Substring(Request.Url.AbsoluteUri.LastIndexOf("/") + 1)
            'thisURL = thisURL.Substring(0, thisURL.IndexOf(".aspx") + 5)
            Dim keyword As New HtmlMeta
            keyword.Name = "keyword"


            Dim description As New HtmlMeta
            description.Name = "Description"


            Dim arwCon As New ArwaniController
            Dim strQ As String = "select * from AddSEO where PageName='" & thisURL.ToLower() & "'"
            Dim dtTable As DataTable = arwCon.ExecuteQuery(strQ)
            Dim iCount As Integer = 0
            If dtTable.Rows.Count > 0 Then
                If Not IsDBNull(dtTable.Rows(0)("Title")) Then Page.Title = dtTable.Rows(0)("Title")
                If Not IsDBNull(dtTable.Rows(0)("keywords")) Then keyword.Content = dtTable.Rows(0)("keywords")
                If Not IsDBNull(dtTable.Rows(0)("Description")) Then description.Content = dtTable.Rows(0)("Description")
            End If

            Page.Header.Controls.Add(keyword)
            Page.Header.Controls.Add(description)
        End Sub


        Public Sub setDivisionSettings()
            Dim arwCon As New ArwaniController
            Dim strQ As String = "select * from division where divisionid=" & CInt(Request.QueryString("divid"))
            Dim dtTable As DataTable = arwCon.ExecuteQuery(strQ)
            Dim iCount As Integer = 0
            If dtTable.Rows.Count > 0 Then
                If Not IsDBNull(dtTable.Rows(0)("divisiontitle")) Then Division_Title = dtTable.Rows(0)("divisiontitle")
                If Not IsDBNull(dtTable.Rows(0)("backgroundimage")) Then Division_Lower_Background = getDivisionImage(dtTable.Rows(0)("backgroundimage"))
                If Not IsDBNull(dtTable.Rows(0)("header_image")) Then Division_Header = getDivisionFlash(dtTable.Rows(0)("flash"))
                If Not IsDBNull(dtTable.Rows(0)("main_banner")) Then Division_Banner = getDivisionImage(dtTable.Rows(0)("main_banner"))
            End If
        End Sub
        Public Sub loadSliders()
            Dim arrDataStartalign() As String = {"right,bottom", "top,right", "left,bottom", "right,top", "center,top", "right,bottom", "center,bottom"}
             
            Dim arrDataZoom() As String = {"in", "out"}
            

            Dim arrDataTransition() As String = {"fade", "slide"}
             

            Dim arrDataZoomFact() As String = {"1", "1.2", "1.1", "1.3", "1.5", "1.9", "1.0"}
            

            Dim arrDataPanduration() As String = {"12", "14", "18", "9", "10", "17", "13"}
             

            Dim arrDataEndAlign() As String = {"center,top", "left,bottom", "center,center", "center,bottom", "right,top", "right,bottom", "center,right"}  

            Dim DataStartalign As Integer = 0
            Dim DataZoom As Integer = 0
            Dim DataZoomFact As Integer = 0
            Dim DataTransition As Integer = 0
            Dim DataEndAlign As Integer = 0
            Dim DataPanduration As Integer = 0

            Dim arwCon As New ArwaniController
            Dim strQ As String = "select * from division_slider where divisionid=" & CInt(Request.QueryString("divid")) & " order by sortorder"
            Dim dtTable As DataTable = arwCon.ExecuteQuery(strQ)
            Dim iCount As Integer = 0
            If dtTable.Rows.Count > 0 Then
                For iCount = 0 To dtTable.Rows.Count - 1

                    SliderText &= "<li data-transition='" & arrDataTransition(DataTransition) & "' data-startalign='" & arrDataStartalign(DataStartalign) & "' data-zoom='" & arrDataZoom(DataZoom) & "' data-zoomfact='" & arrDataZoomFact(DataZoomFact) & "' data-endalign='" & arrDataEndAlign(DataEndAlign) & "' data-panduration='" & arrDataPanduration(DataPanduration) & "' data-colortransition='4'><img alt='' src='" & getImage(dtTable.Rows(iCount)("banner")) & "' />"
                    SliderText &= "<div class='creative_layer'>"
                    SliderText &= "<div class='cp-left faderight'>"
                    SliderText &= "<p class='cp-title'>&nbsp; </p>"
                    SliderText &= "<div class='clear'> </div>"
                    SliderText &= "</div>"
                    SliderText &= "</div>"
                    SliderText &= "</li>"

                    DataStartalign = DataStartalign + 1
                    If DataStartalign = 7 Then
                        DataStartalign = 0
                    End If
                    DataZoom = DataZoom + 1
                    If DataZoom = 2 Then
                        DataZoom = 0
                    End If
                    DataZoomFact = DataZoomFact + 1
                    If DataZoomFact = 7 Then
                        DataZoomFact = 0
                    End If

                    DataTransition = DataTransition + 1
                    If DataTransition = 2 Then
                        DataTransition = 0
                    End If
                    DataEndAlign = DataEndAlign + 1
                    If DataEndAlign = 7 Then
                        DataEndAlign = 0
                    End If

                    DataPanduration = DataPanduration + 1
                    If DataPanduration = 7 Then
                        DataPanduration = 0
                    End If
                Next

            End If
        End Sub
        '
        '        

        '            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem
        '            Ipsum has been the industry's standard dummy text ever since the 1500s.</div>
        '        <img src="<%=Division_Banner%>" width="971" height="396" alt="slider" /></div>

        Public Function getDivisionFlash(ByVal strFlash As String) As String
            Dim strReturn As String = "images/division_bg.png"
            If File.Exists(Server.MapPath("Flash/" & strFlash)) Then
                strReturn = "Flash/" & strFlash
            End If
            Return strReturn
        End Function

        Public Function getDivisionImage(ByVal imgSrc As String) As String
            Dim strReturn As String = "images/division_bg.png"
            If File.Exists(Server.MapPath("Divisions/" & imgSrc)) Then
                strReturn = "Divisions/" & imgSrc
            End If
            Return strReturn
        End Function

        Public Function getImage(ByVal imgSrc As String) As String
            Dim strReturn As String = "images/main_banner.png"
            If File.Exists(Server.MapPath("Slider/" & imgSrc)) Then
                strReturn = "Slider/" & imgSrc
            End If
            Return strReturn
        End Function


    End Class

End Namespace